local skel = fk.CreateSkill {
  name = "rmt__shuzhou",
}

Fk:loadTranslationTable{
  ["rmt__shuzhou"] = "束州",
  [":rmt__shuzhou"] = "准备阶段，你可以令其他角色依次选择是否交给你一张牌，然后直到你下次发动此技能，这些角色中选择交出牌和"..
  "不交出牌的角色相互造成的伤害+1。",

  ["#rmt__shuzhou-invoke"] = "束州：你可以令所有其他角色选择是否交给你一张牌",
  ["#rmt__shuzhou-give"] = "束州：是否交给 %src 一张牌？",
  ["@rmt__shuzhou_give"] = "<font color='#ff0033'>束州:交出牌</font>",
  ["@rmt__shuzhou_nogive"] = "<font color='#3399ff'>束州:未交牌</font>",

  ["$rmt__shuzhou1"] = "持节北度，镇慰州郡，效祖先故事。",
  ["$rmt__shuzhou2"] = "拥兵专地、不尊汉辞，天下可复救乎？",
}


skel:addEffect(fk.EventPhaseStart, {
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(skel.name) and player.phase == Player.Start and #player.room.alive_players > 1
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askToSkillInvoke(player, { skill_name = skel.name, prompt = "#rmt__shuzhou-invoke" })
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:doIndicate(player, room:getOtherPlayers(player))
    room.tag[skel.name] = room.tag[skel.name] or {}
    if room.tag[skel.name][string.format("%.0f", player.id)] then
      local record = room.tag[skel.name][string.format("%.0f", player.id)]
      for _, p in ipairs(room:getOtherPlayers(player)) do
        if table.contains(record[1], p.id) then
          room:removePlayerMark(p, "@rmt__shuzhou_give", 1)
        elseif table.contains(record[2], p.id) then
          room:removePlayerMark(p, "@rmt__shuzhou_nogive", 1)
        end
      end
    end
    local record = {{}, {}}
    for _, p in ipairs(room:getOtherPlayers(player)) do
      if player.dead then break end
      if not p.dead then
        local give = {}
        if not p:isNude() then
          give = room:askToCards(p, {
            min_num = 1, max_num = 1, include_equip = true, cancelable = true, skill_name = skel.name,
            prompt = "#rmt__shuzhou-give:"..player.id
          })
        end
        if #give > 0 then
          room:addPlayerMark(p, "@rmt__shuzhou_give", 1)
          table.insert(record[1], p.id)
          room:moveCardTo(give, Card.PlayerHand, player, fk.ReasonGive, skel.name, nil, false, p)
        else
          room:addPlayerMark(p, "@rmt__shuzhou_nogive", 1)
          table.insert(record[2], p.id)
        end
      end
    end
    room.tag[skel.name][string.format("%.0f", player.id)] = record
  end,
})

skel:addEffect(fk.DamageCaused, {
  can_refresh = function (self, event, target, player, data)
    return target and target == player and player.room.tag[skel.name]
  end,
  on_refresh = function (self, event, target, player, data)
    local n = 0
    for _, record in pairs(player.room.tag[skel.name]) do
      if table.contains(record[1], player.id) and table.contains(record[2], data.to.id) then
        n = n + 1
      end
      if table.contains(record[2], player.id) and table.contains(record[1], data.to.id) then
        n = n + 1
      end
    end
    data:changeDamage(n)
  end,
})



return skel
